package test.db.mysql.table;

import test.db.util.DBUtil;

public enum AuthorityTable implements Table {
    SID(Column.sid),
    AUTHORITY(Column.authority),
    USER_SID(Column.userSid);
    
    private final Column column;
    private static final String TYPE_SID = "VARCHAR(20)";
    private static final String TYPE_AUTHORITY = "VARCHAR(64)";
    private static final String TYPE_USER_SID = "VARCHAR(20)";

    AuthorityTable(Column column) {
        this.column = column;
    }
    
    private enum Column {
        sid {
            String getType() {
                return TYPE_SID;
            }
        },
        
        authority {
            String getType() {
                return TYPE_AUTHORITY;
            }
        },
        
        userSid {
            String getType() {
                return TYPE_USER_SID;
            }
        };
        
        abstract String getType();
    }
    
    public String getType() {
        return column.getType();
    }
    
    public void initData() throws Exception {
        DBUtil.addData("INSERT INTO AUTHORITY VALUES ('00000000000000000000', 'ROLE_SUPER_USER', '00000000000000000000')");
        DBUtil.addData("INSERT INTO AUTHORITY VALUES ('20091212121211111111', 'ROLE_SUPER_USER', '20091212121211111111')");
        DBUtil.addData("INSERT INTO AUTHORITY VALUES ('20091212121211111113', 'ROLE_USER', '20091212121211111111')");
        DBUtil.addData("INSERT INTO AUTHORITY VALUES ('20091212121211111114', 'ROLE_USER_READ', '20091212121211111111')");
        DBUtil.addData("INSERT INTO AUTHORITY VALUES ('20091212121211111112', 'ROLE_USER', '20091212121211111112')");
    }
}